Questions
Age effect - General Questions
source("load_libraries.R")
source("functions.R")
load("../results/dge/gene_length.RData")
load("../results/dge/metadata.RData")
load("../results/dge/norm_counts.RData")
load("../results/dge/dge.RData")
load("../results/dge/dge_net.RData")
load("../results/dge/dge_layout.RData")
load("../results/dge/dge_net_connected_gene_colors.RData")
load("../results/dge/dge_net_pal2.RData")
module_nb = length(unique(connected_gene_colors))
#pal2 = c(pal2, "white", "black")
# Interactions between ages, types and genders
F_SPF_52w_8w = results(dge,contrast= c(0,0,0,0,1,0,0,0,0,0), alpha=0.05, test="Wald")
F_GF_52w_8w = results(dge,contrast= c(0,0,0,0,1,0,0,0,0,1), alpha=0.05, test="Wald")
M_SPF_52w_8w = results(dge,contrast= c(0,0,0,0,1,0,1,0,0,0), alpha=0.05, test="Wald")
M_GF_52w_8w = results(dge,contrast= c(0,0,0,0,1,0,1,0,0,1), alpha=0.05, test="Wald")
F_SPF_104w_8w = results(dge,contrast= c(0,0,0,1,0,0,0,0,0,0), alpha=0.05, test="Wald")
F_GF_104w_8w = results(dge,contrast= c(0,0,0,1,0,0,0,0,1,0), alpha=0.05, test="Wald")
M_SPF_104w_8w = results(dge,contrast= c(0,0,0,1,0,1,0,0,0,0), alpha=0.05, test="Wald")
M_GF_104w_8w = results(dge,contrast= c(0,0,0,1,0,1,0,0,1,0), alpha=0.05, test="Wald")
F_SPF_104w_52w = results(dge,contrast= c(0,0,0,1,-1,0,0,0,0,0), alpha=0.05, test="Wald")
F_GF_104w_52w = results(dge,contrast= c(0,0,0,1,-1,0,0,0,1,-1), alpha=0.05, test="Wald")
M_SPF_104w_52w = results(dge,contrast= c(0,0,0,1,-1,1,-1,0,0,0), alpha=0.05, test="Wald")
M_GF_104w_52w = results(dge,contrast= c(0,0,0,1,-1,1,-1,0,1,-1), alpha=0.05, test="Wald")
to_comp = c("52w VS 8w (F, SPF)","52w VS 8w (F, GF)", "52w VS 8w (M, SPF)", "52w VS 8w (M, GF)",
"104w VS 52w (F, SPF)", "104w VS 52w (F, GF)", "104w VS 52w (M, SPF)", "104w VS 52w (M, GF)",
"104w VS 8w (F, SPF)", "104w VS 8w (F, GF)", "104w VS 8w (M, SPF)", "104w VS 8w (M, GF)")
tga_col_order = c(grep("SPF_8w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_52w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_8w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_52w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_8w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_52w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_8w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_52w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE))
tga_annot_col = as.data.frame(colData(dge)[, c("age","gender", "type")])
tga_annot_col$age = factor(tga_annot_col$age,c("8w", "52w", "104w"))
gta_col_order = c(grep("SPF_8w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_52w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_8w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_52w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_8w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_52w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_8w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_52w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE))
gta_annot_col = as.data.frame(colData(dge)[, c("age","type", "gender")])
gta_annot_col$age = factor(gta_annot_col$age,c("8w", "52w", "104w"))
age_type_gender_data = list(F_SPF_52w_8w, F_GF_52w_8w, M_SPF_52w_8w, M_GF_52w_8w,
F_SPF_104w_52w, F_GF_104w_52w, M_SPF_104w_52w, M_GF_104w_52w,
F_SPF_104w_8w, F_GF_104w_8w, M_SPF_104w_8w, M_GF_104w_8w)
names(age_type_gender_data) = to_comp
age_type_gender_deg = extract_diff_expr_genes(age_type_gender_data, "age-effect/age_type_gender/")
age_type_gender_deg$stat
plot_stat_mat(age_type_gender_deg$stat)
# Differentially expressed genes
upset(as.data.frame(age_type_gender_deg$deg),nsets = 6)
upset(as.data.frame(1*(!is.na(age_type_gender_deg$sign_fc_deg))),nsets = 6)
fc_annot = data.frame(comp = c(rep("52w VS 8w",4), rep("104w VS 52w",4), rep("104w VS 8w",4)),
gender = rep(c(rep("F",2),rep("M",2)),3),
type = rep(c("SPF","GF"),6))
rownames(fc_annot) = colnames(age_type_gender_deg$sign_fc_deg)
plot_fc_heatmap(age_type_gender_deg$sign_fc_deg, fc_annot)
plot_z_score_heatmap(z_scores,
rownames(age_type_gender_deg$sign_fc_deg),
tga_col_order,
tga_annot_col,
"All DE genes in comparison between the ages for the genders and types",
tga_col_order)
comps = list(
"52w VS 8w (F, SPF)" = c(grep("SPF_8w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_52w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"104w VS 52w (F, SPF)" = c(grep("SPF_52w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"104w VS 8w (F, SPF)" = c(grep("SPF_8w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"52w VS 8w (M, SPF)" = c(grep("SPF_8w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_52w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"104w VS 52w (M, SPF)" = c(grep("SPF_52w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"104w VS 8w (M, SPF)" = c(grep("SPF_8w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"52w VS 8w (F, GF)" = c(grep("GF_8w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_52w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"104w VS 52w (F, GF)" = c(grep("GF_52w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"104w VS 8w (F, GF)" = c(grep("GF_8w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"52w VS 8w (M, GF)" = c(grep("GF_8w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_52w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"104w VS 52w (M, GF)" = c(grep("GF_52w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"104w VS 8w (M, GF)" = c(grep("GF_8w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE))
)
for(comp in names(comps)){
plot_z_score_heatmap(z_scores,
rownames(age_type_gender_deg$sign_fc_deg)[!is.na(age_type_gender_deg$sign_fc_deg[,comp])],
tga_col_order,
tga_annot_col,
paste("DE genes in", comp),
comps[[comp]])
}
plot_z_score_heatmap(z_scores,
rownames(age_type_gender_deg$sign_fc_deg),
gta_col_order,
gta_annot_col,
"All DE genes in comparison between the ages for the genders and types",
gta_col_order)
comps = list(
"52w VS 8w (F, SPF)" = c(grep("SPF_8w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_52w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"52w VS 8w (F, GF)" = c(grep("GF_8w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_52w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"104w VS 52w (F, SPF)" = c(grep("SPF_52w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"104w VS 52w (F, GF)" = c(grep("GF_52w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"104w VS 8w (F, SPF)" = c(grep("SPF_8w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"104w VS 8w (F, GF)" = c(grep("GF_8w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"52w VS 8w (M, SPF)" = c(grep("SPF_8w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_52w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"52w VS 8w (M, GF)" = c(grep("GF_8w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_52w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"104w VS 52w (M, SPF)" = c(grep("SPF_52w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"104w VS 52w (M, GF)" = c(grep("GF_52w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"104w VS 8w (M, SPF)" = c(grep("SPF_8w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("SPF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE)),
"104w VS 8w (M, GF)" = c(grep("GF_8w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
grep("GF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE))
)
for(comp in names(comps)){
plot_z_score_heatmap(z_scores,
rownames(age_type_gender_deg$sign_fc_deg)[!is.na(age_type_gender_deg$sign_fc_deg[,comp])],
gta_col_order,
gta_annot_col,
paste("DE genes in", comp),
comps[[comp]])
}
| 52w VS 8w | M | F |
|---|---|---|
| SPF | ||
| GF |
#par(mfrow=c(2,2),mar=c(0,0,0,0))
#col_52w_vs_8w_F_GF = get_deg_colors(age_type_gender_deg, "52w VS 8w (M, SPF)", connected_gene_colors, module_nb)
#plot_net_with_layout(net, col_52w_vs_8w_F_GF, pal2, layout, add_legend=F)
#col_52w_vs_8w_M_GF = get_deg_colors(age_type_gender_deg, "52w VS 8w (F, SPF)", connected_gene_colors, module_nb)
#plot_net_with_layout(net, col_52w_vs_8w_M_GF, pal2, layout, add_legend=F)
#col_52w_vs_8w_F_SPF = get_deg_colors(age_type_gender_deg, "52w VS 8w (M, GF)", connected_gene_colors, module_nb)
#plot_net_with_layout(net, col_52w_vs_8w_F_SPF, pal2, layout, add_legend=F)
#col_52w_vs_8w_M_SPF = get_deg_colors(age_type_gender_deg, "52w VS 8w (F, GF)", connected_gene_colors, module_nb)
#plot_net_with_layout(net, col_52w_vs_8w_M_SPF, pal2, layout, add_legend=F)
| 104w VS 52w | M | F |
|---|---|---|
| SPF | ||
| GF |
#par(mfrow=c(2,2),mar=c(0,0,0,0))
#col_104w_vs_52w_F_GF = get_deg_colors(age_type_gender_deg, "104w VS 52w (M, SPF)", connected_gene_colors, module_nb)
#plot_net_with_layout(net, col_104w_vs_52w_F_GF, pal2, layout, add_legend=F)
#col_104w_vs_52w_M_GF = get_deg_colors(age_type_gender_deg, "104w VS 52w (F, SPF)", connected_gene_colors, module_nb)
#plot_net_with_layout(net, col_104w_vs_52w_M_GF, pal2, layout, add_legend=F)
#col_104w_vs_52w_F_SPF = get_deg_colors(age_type_gender_deg, "104w VS 52w (M, GF)", connected_gene_colors, module_nb)
#plot_net_with_layout(net, col_104w_vs_52w_F_SPF, pal2, layout, add_legend=F)
#col_104w_vs_52w_M_SPF = get_deg_colors(age_type_gender_deg, "104w VS 52w (F, GF)", connected_gene_colors, module_nb)
#plot_net_with_layout(net, col_104w_vs_52w_M_SPF, pal2, layout, add_legend=F)
mod_pal = pal2
names(mod_pal) = paste("ME", names(pal2), sep='')
names(mod_pal) = replace(names(mod_pal), which(names(mod_pal) == 'ME0'), "No module")
annot_colors = list(
module = mod_pal
)
plot_z_score_heatmap_with_modules(z_scores,
rownames(z_scores),
tga_col_order,
tga_annot_col,
"All genes")
comps = c("52w VS 8w (F, SPF)","104w VS 52w (F, SPF)","104w VS 8w (F, SPF)",
"52w VS 8w (M, SPF)","104w VS 52w (M, SPF)", "104w VS 8w (M, SPF)",
"52w VS 8w (F, GF)", "104w VS 52w (F, GF)", "104w VS 8w (F, GF)",
"52w VS 8w (M, GF)", "104w VS 52w (M, GF)", "104w VS 8w (M, GF)")
for(comp in comps){
plot_z_score_heatmap_with_modules(z_scores,
rownames(age_type_gender_deg$sign_fc_deg)[!is.na(age_type_gender_deg$sign_fc_deg[,comp])],
tga_col_order,
tga_annot_col,
paste("DE genes in", comp))
}
plot_z_score_heatmap_with_modules(z_scores,
rownames(z_scores),
gta_col_order,
gta_annot_col,
"All genes")
comps = c("52w VS 8w (F, SPF)","52w VS 8w (F, GF)",
"104w VS 52w (F, SPF)","104w VS 52w (F, GF)",
"104w VS 8w (F, SPF)","104w VS 8w (F, GF)",
"52w VS 8w (M, SPF)","52w VS 8w (M, GF)",
"104w VS 52w (M, SPF)","104w VS 52w (M, GF)",
"104w VS 8w (M, SPF)","104w VS 8w (M, GF)")
for(comp in comps){
plot_z_score_heatmap_with_modules(z_scores,
rownames(age_type_gender_deg$sign_fc_deg)[!is.na(age_type_gender_deg$sign_fc_deg[,comp])],
gta_col_order,
gta_annot_col,
paste("DE genes in", comp))
}
comps = c("52w VS 8w (F, SPF)","52w VS 8w (F, GF)",
"104w VS 52w (F, SPF)","104w VS 52w (F, GF)",
"104w VS 8w (F, SPF)","104w VS 8w (F, GF)",
"52w VS 8w (M, SPF)","52w VS 8w (M, GF)",
"104w VS 52w (M, SPF)","104w VS 52w (M, GF)",
"104w VS 8w (M, SPF)","104w VS 8w (M, GF)")
for(comp in comps){
plot_top_deg_in_modules(age_type_gender_deg$sign_fc_deg, comp, connected_gene_colors)
}
options(repr.plot.width=7, repr.plot.height=7)
full_go_desc = age_type_gender_deg$GO_wall[[1]][,"term"]
names(full_go_desc) = age_type_gender_deg$GO_wall[[1]][,"category"]
comp = colnames(age_type_gender_deg$over_represented_GO)
comp = comp[4:length(comp)]
Dot-plot with the most over-represented BP GO (20 most significant p-values for the different comparison)
plot_top_go(age_type_gender_deg,
"BP",
40)
Network based on description similarity
BP_network = create_GO_network(age_type_gender_deg, "BP", BP_GO)
| 52w VS 8w | M | F |
|---|---|---|
| SPF | ||
| GF |
par(mfrow=c(2,2),mar=c(0,0,0,0))
plot_GO_networks(BP_network, "52w VS 8w (M, SPF)", full_go_desc, plot_interactive = FALSE)
plot_GO_networks(BP_network, "52w VS 8w (F, SPF)", full_go_desc, plot_interactive = FALSE)
plot_GO_networks(BP_network, "52w VS 8w (M, GF)", full_go_desc, plot_interactive = FALSE)
plot_GO_networks(BP_network, "52w VS 8w (F, GF)", full_go_desc, plot_interactive = FALSE)
col = get_GO_network_col(BP_network, "52w VS 8w (M, SPF)")
dotRes = getAmigoTree(goIDs=names(col),
color=col,
filename="../results/dge/age-effect/age_type_gender/go/52w_VS_8w_M_SPF",
picType="png",
saveResult=TRUE)

GO Tree at "../results/dge/age-effect/age_type_gender/go/52w_VS_8w_M_SPF.png"
col = get_GO_network_col(BP_network, "52w VS 8w (F, SPF)")
dotRes = getAmigoTree(goIDs=names(col),
color=col,
filename="../results/dge/age-effect/age_type_gender/go/52w_VS_8w_F_SPF",
picType="png",
saveResult=TRUE)

GO Tree at "../results/dge/age-effect/age_type_gender/go/52w_VS_8w_F_SPF.png"
col = get_GO_network_col(BP_network, "52w VS 8w (M, GF)")
dotRes = getAmigoTree(goIDs=names(col),
color=col,
filename="../results/dge/age-effect/age_type_gender/go/52w_VS_8w_M_GF",
picType="png",
saveResult=TRUE)

GO Tree at "../results/dge/age-effect/age_type_gender/go/52w_VS_8w_M_GF.png"
col = get_GO_network_col(BP_network, "52w VS 8w (F, GF)")
dotRes = getAmigoTree(goIDs=names(col),
color=col,
filename="../results/dge/age-effect/age_type_gender/go/52w_VS_8w_F_GF",
picType="png",
saveResult=TRUE)

GO Tree at "../results/dge/age-effect/age_type_gender/go/52w_VS_8w_F_GF.png"
| 104w VS 52w | M | F |
|---|---|---|
| SPF | ||
| GF |
par(mfrow=c(2,2),mar=c(0,0,0,0))
plot_GO_networks(BP_network, "104w VS 52w (M, SPF)", full_go_desc, plot_interactive = FALSE)
plot_GO_networks(BP_network, "104w VS 52w (F, SPF)", full_go_desc, plot_interactive = FALSE)
plot_GO_networks(BP_network, "104w VS 52w (M, GF)", full_go_desc, plot_interactive = FALSE)
plot_GO_networks(BP_network, "104w VS 52w (F, GF)", full_go_desc, plot_interactive = FALSE)
col = get_GO_network_col(BP_network, "104w VS 52w (M, SPF)")
dotRes = getAmigoTree(goIDs=names(col),
color=col,
filename="../results/dge/age-effect/age_type_gender/go/104w_VS_52w_M_SPF",
picType="png",
saveResult=TRUE)

GO Tree at "../results/dge/age-effect/age_type_gender/go/104w_VS_52w_M_SPF.png"
col = get_GO_network_col(BP_network, "104w VS 52w (F, SPF)")
dotRes = getAmigoTree(goIDs=names(col),
color=col,
filename="../results/dge/age-effect/age_type_gender/go/104w_VS_52w_F_SPF",
picType="png",
saveResult=TRUE)

GO Tree at "../results/dge/age-effect/age_type_gender/go/104w_VS_52w_F_SPF.png"
col = get_GO_network_col(BP_network, "104w VS 52w (M, GF)")
dotRes = getAmigoTree(goIDs=names(col),
color=col,
filename="../results/dge/age-effect/age_type_gender/go/104w_VS_52w_M_GF",
picType="png",
saveResult=TRUE)

GO Tree at "../results/dge/age-effect/age_type_gender/go/104w_VS_52w_M_GF.png"
col = get_GO_network_col(BP_network, "104w VS 52w (F, GF)")
dotRes = getAmigoTree(goIDs=names(col),
color=col,
filename="../results/dge/age-effect/age_type_gender/go/104w_VS_52w_F_GF",
picType="png",
saveResult=TRUE)

GO Tree at "../results/dge/age-effect/age_type_gender/go/104w_VS_52w_F_GF.png"
| 104w VS 8w | M | F |
|---|---|---|
| SPF | ||
| GF |
par(mfrow=c(2,2),mar=c(0,0,0,0))
plot_GO_networks(BP_network, "104w VS 8w (M, SPF)", full_go_desc, plot_interactive = FALSE)
plot_GO_networks(BP_network, "104w VS 8w (F, SPF)", full_go_desc, plot_interactive = FALSE)
plot_GO_networks(BP_network, "104w VS 8w (M, GF)", full_go_desc, plot_interactive = FALSE)
plot_GO_networks(BP_network, "104w VS 8w (F, GF)", full_go_desc, plot_interactive = FALSE)
col = get_GO_network_col(BP_network, "104w VS 8w (M, SPF)")
dotRes = getAmigoTree(goIDs=names(col),
color=col,
filename="../results/dge/age-effect/age_type_gender/go/104w_VS_8w_M_SPF",
picType="png",
saveResult=TRUE)

GO Tree at "../results/dge/age-effect/age_type_gender/go/104w_VS_52w_M_SPF.png"
col = get_GO_network_col(BP_network, "104w VS 8w (F, SPF)")
dotRes = getAmigoTree(goIDs=names(col),
color=col,
filename="../results/dge/age-effect/age_type_gender/go/104w_VS_8w_F_SPF",
picType="png",
saveResult=TRUE)

GO Tree at "../results/dge/age-effect/age_type_gender/go/104w_VS_52w_F_SPF.png"
col = get_GO_network_col(BP_network, "104w VS 8w (M, GF)")
dotRes = getAmigoTree(goIDs=names(col),
color=col,
filename="../results/dge/age-effect/age_type_gender/go/104w_VS_8w_M_GF",
picType="png",
saveResult=TRUE)

GO Tree at "../results/dge/age-effect/age_type_gender/go/104w_VS_52w_M_GF.png"
col = get_GO_network_col(BP_network, "104w VS 8w (F, GF)")
dotRes = getAmigoTree(goIDs=names(col),
color=col,
filename="../results/dge/age-effect/age_type_gender/go/104w_VS_8w_F_GF",
picType="png",
saveResult=TRUE)

GO Tree at "../results/dge/age-effect/age_type_gender/go/104w_VS_52w_F_GF.png"
Dot-plot with the most over-represented CC GO (20 most significant p-values for the different comparison)
plot_top_go(age_type_gender_deg,
"CC",
40)
Dot-plot with the most over-represented MF GO (20 most significant p-values for the different comparison)
plot_top_go(age_type_gender_deg,
"MF",
40)
plot_kegg_pathways(age_type_gender_deg$over_represented_KEGG[,"category"],
age_type_gender_deg$fc_deg,
"../results/dge/age-effect/age_type_gender/kegg/over_repr_kegg/")
plot_kegg_pathways(age_type_gender_deg$under_represented_KEGG[,"category"],
age_type_gender_deg$fc_deg,
"../results/dge/age-effect/age_type_gender/kegg/under_repr_kegg/")
Genes:
Genes in "../results/dge/age-effect/age_type_gender/spf_f_aging_genes"
spf_f_aging = list()
spf_f_aging$deg_52w_vs_8w = rownames(age_type_gender_deg$fc_deg[!is.na(age_type_gender_deg$fc_deg[,"52w VS 8w (F, SPF)"]),])
spf_f_aging$deg_104w_vs_52w = rownames(age_type_gender_deg$fc_deg[!is.na(age_type_gender_deg$fc_deg[,"104w VS 52w (F, SPF)"]),])
spf_f_aging$deg_52w_vs_8w_and_104w_vs_52w = rownames(age_type_gender_deg$fc_deg[!is.na(age_type_gender_deg$fc_deg[,"52w VS 8w (F, SPF)"]) & !is.na(age_type_gender_deg$fc_deg[,"104w VS 52w (F, SPF)"]),])
sapply(spf_f_aging, length)
capture.output(spf_f_aging, file = "../results/dge/age-effect/age_type_gender/spf_f_aging_genes")
col_1 = rep("52w != 8w (SPF)", length(spf_f_aging$deg_52w_vs_8w))
col_1[spf_f_aging$deg_52w_vs_8w %in% spf_f_aging$deg_52w_vs_8w_and_104w_vs_52w] = "52w != 8w (SPF) and 104w != 52w (SPF)"
log2fc_deg_52w_vs_8w = data.frame(SPF_52w_vs_8w = age_type_gender_deg$fc_deg[spf_f_aging$deg_52w_vs_8w, "52w VS 8w (F, SPF)"],
GF_52w_vs_8w = age_type_gender_deg$fc_deg[spf_f_aging$deg_52w_vs_8w, "52w VS 8w (F, GF)"],
GF_104w_vs_52w = age_type_gender_deg$fc_deg[spf_f_aging$deg_52w_vs_8w, "104w VS 52w (F, GF)"],
genes = spf_f_aging$deg_52w_vs_8w,
provenance = col_1)
col_2 = rep("104w != 52w (SPF)", length(spf_f_aging$deg_104w_vs_52w))
col_2[spf_f_aging$deg_104w_vs_52w %in% spf_f_aging$deg_52w_vs_8w_and_104w_vs_52w] = "52w != 8w (SPF) and 104w != 52w (SPF)"
log2fc_deg_104w_vs_52w = data.frame(SPF_104w_vs_52w = age_type_gender_deg$fc_deg[spf_f_aging$deg_104w_vs_52w, "104w VS 52w (F, SPF)"],
GF_52w_vs_8w = age_type_gender_deg$fc_deg[spf_f_aging$deg_104w_vs_52w, "52w VS 8w (F, GF)"],
GF_104w_vs_52w = age_type_gender_deg$fc_deg[spf_f_aging$deg_104w_vs_52w, "104w VS 52w (F, GF)"],
genes = spf_f_aging$deg_104w_vs_52w,
provenance = col_2)
pal = c(rgb(0.5,0.5,1), rgb(0.5,1,0.5,alpha=0.5), rgb(1,0.5,0.5,alpha=0.5))
pal = setNames(pal, c("52w != 8w (SPF)", "104w != 52w (SPF)", "52w != 8w (SPF) and 104w != 52w (SPF)"))
p1 = plot_ly(log2fc_deg_52w_vs_8w,
x = ~SPF_52w_vs_8w,
y = ~GF_52w_vs_8w,
text = paste("Gene: ", log2fc_deg_52w_vs_8w$genes),
mode = "markers",
color = ~provenance,
colors = pal,
legendgroup = ~provenance) %>%
layout(xaxis = list(title = "Log2FC 52w vs 8w (SPF)"), yaxis = list(title = "Log2FC 52w vs 8w (GF)"))
p2 = plot_ly(log2fc_deg_104w_vs_52w,
x = ~SPF_104w_vs_52w,
y = ~GF_52w_vs_8w,
text = paste("Gene: ", log2fc_deg_104w_vs_52w$genes),
mode = "markers",
color = ~provenance,
colors = pal,
legendgroup = ~provenance) %>%
layout(xaxis = list(title = "104w vs 52w (SPF)"), yaxis = list(title = "52w vs 8w (GF)"))
p3 = plot_ly(log2fc_deg_52w_vs_8w,
x = ~SPF_52w_vs_8w,
y = ~GF_104w_vs_52w,
text = paste("Gene: ", log2fc_deg_52w_vs_8w$genes),
mode = "markers",
color = ~provenance,
colors = pal,
legendgroup = ~provenance) %>%
layout(xaxis = list(title = "52w vs 8w (SPF)"), yaxis = list(title = "104w vs 52w (GF)"))
p4 = plot_ly(log2fc_deg_104w_vs_52w,
x = ~SPF_104w_vs_52w,
y = ~GF_104w_vs_52w,
text = paste("Gene: ", log2fc_deg_104w_vs_52w$genes),
mode = "markers",
color = ~provenance,
colors = pal,
legendgroup = ~provenance) %>%
layout(xaxis = list(title = "104w vs 52w (SPF)"), yaxis = list(title = "104w vs 52w (GF)"))
subplot(p1, p2, p3, p4, nrows = 2, shareX = TRUE, shareY = TRUE) %>%
layout(title = "Log2FC") %>% embed_notebook
Genes in "../results/dge/age-effect/age_type_gender/spf_m_aging_genes"
spf_m_aging = list()
spf_m_aging$deg_52w_vs_8w = rownames(age_type_gender_deg$fc_deg[!is.na(age_type_gender_deg$fc_deg[,"52w VS 8w (M, SPF)"]),])
spf_m_aging$deg_104w_vs_52w = rownames(age_type_gender_deg$fc_deg[!is.na(age_type_gender_deg$fc_deg[,"104w VS 52w (M, SPF)"]),])
spf_m_aging$deg_52w_vs_8w_and_104w_vs_52w = rownames(age_type_gender_deg$fc_deg[!is.na(age_type_gender_deg$fc_deg[,"52w VS 8w (M, SPF)"]) & !is.na(age_type_gender_deg$fc_deg[,"104w VS 52w (M, SPF)"]),])
sapply(spf_m_aging, length)
capture.output(spf_m_aging, file = "../results/dge/age-effect/age_type_gender/spf_m_aging_genes")
col_1 = rep("52w != 8w (SPF)", length(spf_m_aging$deg_52w_vs_8w))
col_1[spf_m_aging$deg_52w_vs_8w %in% spf_m_aging$deg_52w_vs_8w_and_104w_vs_52w] = "52w != 8w (SPF) and 104w != 52w (SPF)"
log2fc_deg_52w_vs_8w = data.frame(SPF_52w_vs_8w = age_type_gender_deg$fc_deg[spf_m_aging$deg_52w_vs_8w, "52w VS 8w (M, SPF)"],
GF_52w_vs_8w = age_type_gender_deg$fc_deg[spf_m_aging$deg_52w_vs_8w, "52w VS 8w (M, GF)"],
GF_104w_vs_52w = age_type_gender_deg$fc_deg[spf_m_aging$deg_52w_vs_8w, "104w VS 52w (M, GF)"],
genes = spf_m_aging$deg_52w_vs_8w,
provenance = col_1)
col_2 = rep("104w != 52w (SPF)", length(spf_m_aging$deg_104w_vs_52w))
col_2[spf_m_aging$deg_104w_vs_52w %in% spf_m_aging$deg_52w_vs_8w_and_104w_vs_52w] = "52w != 8w (SPF) and 104w != 52w (SPF)"
log2fc_deg_104w_vs_52w = data.frame(SPF_104w_vs_52w = age_type_gender_deg$fc_deg[spf_m_aging$deg_104w_vs_52w, "104w VS 52w (M, SPF)"],
GF_52w_vs_8w = age_type_gender_deg$fc_deg[spf_m_aging$deg_104w_vs_52w, "52w VS 8w (M, GF)"],
GF_104w_vs_52w = age_type_gender_deg$fc_deg[spf_m_aging$deg_104w_vs_52w, "104w VS 52w (M, GF)"],
genes = spf_m_aging$deg_104w_vs_52w,
provenance = col_2)
#log2fc_deg_52w_vs_8w_and_104w_vs_52w = data.frame(
# SPF_52w_vs_8w = age_type_gender_deg$fc_deg[spf_m_aging$deg_52w_vs_8w_and_104w_vs_52w, "52w VS 8w (M, SPF)"],
# SPF_104w_vs_52w = age_type_gender_deg$fc_deg[spf_m_aging$deg_52w_vs_8w_and_104w_vs_52w, "104w VS 52w (M, SPF)"],
# GF_52w_vs_8w = age_type_gender_deg$fc_deg[spf_m_aging$deg_52w_vs_8w_and_104w_vs_52w, "52w VS 8w (M, GF)"],
# GF_104w_vs_52w = age_type_gender_deg$fc_deg[spf_m_aging$deg_52w_vs_8w_and_104w_vs_52w, "104w VS 52w (M, GF)"],
# genes = spf_m_aging$deg_52w_vs_8w_and_104w_vs_52w)
pal = c(rgb(0.5,0.5,1), rgb(0.5,1,0.5,alpha=0.5), rgb(1,0.5,0.5,alpha=0.5))
pal = setNames(pal, c("52w != 8w (SPF)", "104w != 52w (SPF)", "52w != 8w (SPF) and 104w != 52w (SPF)"))
p1 = plot_ly(log2fc_deg_52w_vs_8w,
x = ~SPF_52w_vs_8w,
y = ~GF_52w_vs_8w,
text = paste("Gene: ", log2fc_deg_52w_vs_8w$genes),
mode = "markers",
color = ~provenance,
colors = pal,
legendgroup = ~provenance) %>%
layout(xaxis = list(title = "52w vs 8w (SPF)"), yaxis = list(title = "52w vs 8w (GF)"))
p2 = plot_ly(log2fc_deg_104w_vs_52w,
x = ~SPF_104w_vs_52w,
y = ~GF_52w_vs_8w,
text = paste("Gene: ", log2fc_deg_104w_vs_52w$genes),
mode = "markers",
color = ~provenance,
colors = pal,
legendgroup = ~provenance) %>%
layout(xaxis = list(title = "104w vs 52w (SPF)"), yaxis = list(title = "52w vs 8w (GF)"))
p3 = plot_ly(log2fc_deg_52w_vs_8w,
x = ~SPF_52w_vs_8w,
y = ~GF_104w_vs_52w,
text = paste("Gene: ", log2fc_deg_52w_vs_8w$genes),
mode = "markers",
color = ~provenance,
colors = pal,
legendgroup = ~provenance) %>%
layout(xaxis = list(title = "52w vs 8w (SPF)"), yaxis = list(title = "104w vs 52w (GF)"))
p4 = plot_ly(log2fc_deg_104w_vs_52w,
x = ~SPF_104w_vs_52w,
y = ~GF_104w_vs_52w,
text = paste("Gene: ", log2fc_deg_104w_vs_52w$genes),
mode = "markers",
color = ~provenance,
colors = pal,
legendgroup = ~provenance) %>%
layout(xaxis = list(title = "104w vs 52w (SPF)"), yaxis = list(title = "104w vs 52w (GF)"))
subplot(p1, p2, p3, p4, nrows = 2, shareX = TRUE, shareY = TRUE) %>%
layout(title = "Log2FC") %>% embed_notebook
comp = "104w VS 8w (F, SPF)"
F_SPF_104w_8w_DEG = rownames(age_type_gender_deg$sign_fc_deg)[!is.na(age_type_gender_deg$sign_fc_deg[,comp])]
F_SPF_104w_8w_DE_FC = age_type_gender_deg$sign_fc_deg[F_SPF_104w_8w_DEG,comp]
names(F_SPF_104w_8w_DE_FC) = F_SPF_104w_8w_DEG
# order by FC
F_SPF_104w_8w_DEG = names(sort(F_SPF_104w_8w_DE_FC))
# selection col to plot
col_to_plot = list("SPF 8w F" = grep("SPF_8w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
"SPF 104w F" = grep("SPF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
"GF 104w F" = grep("GF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE),
"GF 104w M" = grep("GF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE))
main_title = "DE genes in 104w vs 8w (SPF, F)"
Heatmap of the Z-scores of the DEGs (ordered by log2 FC of the comparison 104w VS 8w (F, SPF))
# get DEG data
deg_data = z_scores[F_SPF_104w_8w_DEG, unlist(col_to_plot)]
# plot heatmap
pheatmap(deg_data,
cluster_rows=F,
cluster_cols=F,
show_rownames=F,
show_colnames=F,
annotation_col=gta_annot_col,
annotation_row=NULL,
annotation_colors = NULL,
color=rev(brewer.pal(11, "RdBu")),
breaks = seq(-3.5, 3.5, length=11),
main = main_title)
Heatmap of the Z-scores with hierarchical clustering
# get non DEG data and do hierarchical clustering on them
hc = hclust(dist(deg_data), method = "complete")
c_deg_data = deg_data[hc$order,]
# plot heatmap
pheatmap(c_deg_data,
cluster_rows=F,
cluster_cols=F,
show_rownames=F,
show_colnames=F,
annotation_col=gta_annot_col,
annotation_row=NULL,
annotation_colors = NULL,
color=rev(brewer.pal(11, "RdBu")),
breaks = seq(-3.5, 3.5, length=11),
main = main_title)
mean_z_scores = cbind(apply(z_scores[F_SPF_104w_8w_DEG,col_to_plot[[1]]],1,mean),
apply(z_scores[F_SPF_104w_8w_DEG,col_to_plot[[2]]],1,mean),
apply(z_scores[F_SPF_104w_8w_DEG,col_to_plot[[3]]],1,mean),
apply(z_scores[F_SPF_104w_8w_DEG,col_to_plot[[4]]],1,mean))
colnames(mean_z_scores) = names(col_to_plot)
head(mean_z_scores)
Heatmap of the mean Z-scores per groups of the DEGs (ordered by log2 FC of the comparison 104w VS 8w (F, SPF))
col_annot = data.frame(age = c("8w",rep("104w",3)),
type = c(rep("SPF",2),rep("GF",2)),
gender = c(rep("F",3),"M"))
rownames(col_annot) = c("SPF 8w F","SPF 104w F","GF 104w F","GF 104w M")
pheatmap(mean_z_scores,
cluster_rows=F,
cluster_cols=F,
show_rownames=F,
show_colnames=F,
annotation_col=col_annot,
annotation_row=NULL,
annotation_colors = NULL,
color=rev(brewer.pal(11, "RdBu")),
breaks = seq(-3.5, 3.5, length=11),
main = main_title)
Heatmap of the mean Z-scores per groups of the DEGs (hierarchical clustering)
# get non DEG data and do hierarchical clustering on them
hc = hclust(dist(mean_z_scores), method = "complete")
c_mean_z_scores = mean_z_scores[hc$order,]
#
pheatmap(c_mean_z_scores,
cluster_rows=F,
cluster_cols=F,
show_rownames=F,
show_colnames=F,
annotation_col=col_annot,
annotation_row=NULL,
annotation_colors = NULL,
color=rev(brewer.pal(11, "RdBu")),
breaks = seq(-3.5, 3.5, length=11),
main = main_title)
Plot of the mean Z-score for GF 104w F and GF 104w M samples in function of the log2 FC of the comparison 104w VS 8w (F, SPF)
data = mean_z_scores
x = F_SPF_104w_8w_DE_FC[F_SPF_104w_8w_DEG]
plot(c(min(x), max(x)), c(min(data), max(data)), type= "n", xlab = "Log2 FC of DEG in 104w vs 8w (SPF, F)", ylab = "Mean Z-score")
points(x, data[, 1], col = 1, pch = 20)
points(x, data[, 2], col = 2, pch = 20)
points(x, data[, 3], col = 3, pch = 20)
points(x, data[, 4], col = 4, pch = 20)
legend("topright", col = 1:4, colnames(data), pch = 19)
comp = "104w VS 8w (M, SPF)"
M_SPF_104w_8w_DEG = rownames(age_type_gender_deg$sign_fc_deg)[!is.na(age_type_gender_deg$sign_fc_deg[,comp])]
M_SPF_104w_8w_DE_FC = age_type_gender_deg$sign_fc_deg[M_SPF_104w_8w_DEG,comp]
names(M_SPF_104w_8w_DE_FC) = M_SPF_104w_8w_DEG
# order by FC
M_SPF_104w_8w_DEG = names(sort(M_SPF_104w_8w_DE_FC))
# selection col to plot
col_to_plot = list("SPF 8w M" = grep("SPF_8w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
"SPF 104w M" = grep("SPF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
"GF 104w M" = grep("GF_104w_M_+", colnames(norm_counts), perl=TRUE, value=TRUE),
"GF 104w F" = grep("GF_104w_F_+", colnames(norm_counts), perl=TRUE, value=TRUE))
main_title = "DE genes in 104w vs 8w (SPF, M)"
Heatmap of the Z-scores of the DEGs (ordered by log2 FC of the comparison 104w VS 8w (M, SPF))
# get DEG data
deg_data = z_scores[M_SPF_104w_8w_DEG, unlist(col_to_plot)]
# plot heatmap
pheatmap(deg_data,
cluster_rows=F,
cluster_cols=F,
show_rownames=F,
show_colnames=F,
annotation_col=gta_annot_col,
annotation_row=NULL,
annotation_colors = NULL,
color=rev(brewer.pal(11, "RdBu")),
breaks = seq(-3.5, 3.5, length=11),
main = main_title)
Heatmap of the Z-scores with hierarchical clustering
# get non DEG data and do hierarchical clustering on them
hc = hclust(dist(deg_data), method = "complete")
c_deg_data = deg_data[hc$order,]
# plot heatmap
pheatmap(c_deg_data,
cluster_rows=F,
cluster_cols=F,
show_rownames=F,
show_colnames=F,
annotation_col=gta_annot_col,
annotation_row=NULL,
annotation_colors = NULL,
color=rev(brewer.pal(11, "RdBu")),
breaks = seq(-3.5, 3.5, length=11),
main = main_title)
mean_z_scores = cbind(apply(z_scores[M_SPF_104w_8w_DEG,col_to_plot[[1]]],1,mean),
apply(z_scores[M_SPF_104w_8w_DEG,col_to_plot[[2]]],1,mean),
apply(z_scores[M_SPF_104w_8w_DEG,col_to_plot[[3]]],1,mean),
apply(z_scores[M_SPF_104w_8w_DEG,col_to_plot[[4]]],1,mean))
colnames(mean_z_scores) = names(col_to_plot)
head(mean_z_scores)
Heatmap of the mean Z-scores per groups of the DEGs (ordered by log2 FC of the comparison 104w VS 8w (F, SPF))
col_annot = data.frame(age = c("8w",rep("104w",3)),
type = c(rep("SPF",2),rep("GF",2)),
gender = c(rep("M",3),"F"))
rownames(col_annot) = c("SPF 8w M","SPF 104w M","GF 104w M","GF 104w F")
pheatmap(mean_z_scores,
cluster_rows=F,
cluster_cols=F,
show_rownames=F,
show_colnames=F,
annotation_col=col_annot,
annotation_row=NULL,
annotation_colors = NULL,
color=rev(brewer.pal(11, "RdBu")),
breaks = seq(-3.5, 3.5, length=11),
main = main_title)
Heatmap of the mean Z-scores per groups of the DEGs (hierarchical clustering)
# get non DEG data and do hierarchical clustering on them
hc = hclust(dist(mean_z_scores), method = "complete")
c_mean_z_scores = mean_z_scores[hc$order,]
#
pheatmap(mean_z_scores,
cluster_rows=F,
cluster_cols=F,
show_rownames=F,
show_colnames=F,
annotation_col=col_annot,
annotation_row=NULL,
annotation_colors = NULL,
color=rev(brewer.pal(11, "RdBu")),
breaks = seq(-3.5, 3.5, length=11),
main = main_title)